//
//  MenuListCollectionViewCell.m
//  Happy Kitchen
//
//  Created by mac_chen on 15/3/7.
//  Copyright (c) 2015年 mac_chen. All rights reserved.
//

#import "MenuListCollectionViewCell.h"

@implementation MenuListCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self createSub];
    }
    return self;
}

- (void)createSub

{

    //背景图片
    UIImage *backImage = [UIImage imageNamed:@"back1.jpg"];
    UIImageView *backImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height - 30)];
    backImageView.image = backImage;
    backImageView.backgroundColor = [UIColor redColor];
    backImageView.userInteractionEnabled = YES;
    [self.contentView addSubview:backImageView];
    
    

    //图片
    self.imagePathThumbnailsImageView = [[UIImageView alloc] initWithFrame:CGRectMake(backImageView.frame.origin.x + 5, backImageView.frame.origin.y + 5, backImageView.frame.size.width - 10, backImageView.frame.size.height - 10)];
    
    self.imagePathThumbnailsImageView.backgroundColor = [UIColor redColor];
    self.imagePathThumbnailsImageView.userInteractionEnabled = YES;
    [backImageView addSubview:self.imagePathThumbnailsImageView];
    
    
    
    //美食的名字label
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(backImageView.frame.origin.x, backImageView.frame.size.height, self.contentView.frame.size.width - 70, self.contentView.frame.size.height - backImageView.frame.size.height)];
       self.nameLabel.font = [UIFont systemFontOfSize:11];
//   self.nameLabel.backgroundColor = [UIColor redColor];
//    self.nameLabel.textAlignment = 1;
    [self.contentView addSubview:self.nameLabel];
    
    
    
    //中间的红心图片
    UIImage *image = [UIImage imageNamed:@"click.png"];
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.nameLabel.frame.origin.x + 5 + self.nameLabel.frame.size.width, self.nameLabel.frame.origin.y, self.contentView.frame.size.width/6, self.contentView.frame.size.height - backImageView.frame.size.height)];
    imageView.userInteractionEnabled = YES;
    imageView.image = image;
//    imageView.backgroundColor = [UIColor blueColor];
    [self.contentView addSubview:imageView];

    
    
    
    //点击的次数
    self.clickCountLabel = [[UILabel alloc] initWithFrame:CGRectMake(imageView.frame.origin.x + 5 + imageView.frame.size.width, backImageView.frame.size.height, self.contentView.frame.size.width/5, self.contentView.frame.size.height - backImageView.frame.size.height)];
     self.clickCountLabel.font = [UIFont systemFontOfSize:10];
//    self.clickCountLabel.backgroundColor = [UIColor cyanColor];
   [self.contentView addSubview:self.clickCountLabel];
    
    
    
    
}

//自定义方法
- (void)setMenuList:(MenuList *)menuList
{
    self.nameLabel.text = menuList.name;
    self.clickCountLabel.text = [NSString stringWithFormat:@"%ld", menuList.clickCount];
      self.diseaseDescribeLabel.text = menuList.diseaseDescribe;
    
}
@end
